home *** CD-ROM | disk | FTP | other *** search
- //for use with serial.c by Alec Russell.
-
- #if 0
- /*
-
- code snippets to demo some common functions
-
-
- // returns non-zero if online, ese zero
- /* ---------------------- online() ----------------------- April 23,1995 */
- int online(void)
- {
- msr(); // sets global var sio_modemstat
- return (sio_modemstat & 128); // check online bit
- }
-
-
- char gb_util_str[1024];
-
- // this is just to give some clues - much is in libraries I can't give out
- // dial_d holds phone number, baud etc...
- // twput() prints text in a window
- /* ---------------------- dial_one_entry() ------------- October 21,1992 */
- int dial_one_entry(dial_t *d, serial_232_t *sd)
- {
- int ok, connected, a, i, len, got_text, esc, attempt;
- int color, p_color;
- char last_ret[50];
- clock_t time_out;
-
- color=BCK_BLUE | WHITE;
- p_color=BCK_BLUE | YELLOW;
-
- ok=FALSE;
-
- // dial dir holds boud etc... for each entry
- // change to correct setting if neccessary
- if ( sd->baud != d->baud )
- {
- /* change baud rate */
- deinit_232();
- sd->baud=d->baud;
- if ( init_232(sd) )
- {
- ok=FALSE;
- return(ok);
- }
-
- /* update status line */
- a=get_old_idt();
- select_twindow(25000);
- print_status_line(sd);
- select_twindow(a);
- }
-
- twput(2, 15, color, "══════════════════════════════════════");
- twput(2, 15, color, "╡ ESC to exit ╞");
-
-
- strcpy(last_ret, "NONE");
- connected=FALSE;
- esc=FALSE;
- attempt=0;
- do
- {
- clear_wt(0);
- flush_232_rcv();
- delay(t_parm.dial_pause);
-
- if ( bioskey(1) ) // if a key is pressed
- {
- a=getk();
- if ( a == ESC )
- esc=TRUE;
- }
-
-
- /* print status on screen */
- twput(3,2, p_color, "DIALING:");
- sprintf(gb_util_str, "%s at %s", d->name, d->number);
- twput(12,2, color, gb_util_str);
- twput(3,4, p_color, "Attempt #");
- sprintf(gb_util_str, "%d", ++attempt);
- twput(12,4, color, gb_util_str);
- twput(3,6, p_color, "Last Result:");
- sprintf(gb_util_str, "%s", last_ret);
- twput(16,6, color, gb_util_str);
-
- /* send dial string to modem */
- sprintf(gb_util_str, "ATD%c%s\r",
- t_parm.tone ? 'T' : 'P',
- d->number);
- got_text=0;
- len=strlen(gb_util_str);
- for ( i=0; i < len; i++ )
- send_232((int)gb_util_str[i]);
-
-
- // this is OLD code, and can be more generic/robust
- /* wait for reply from modem */
- time_out=clock() + t_parm.dial_timeout;
- i=0;
- memset(gb_util_str, 0, 256);
- do
- {
- if ( char_ready_232() )
- {
- gb_util_str[i]=get_232();
- i++;
-
- if ( strstr(gb_util_str, "BUSY") )
- {
- strcpy(last_ret, "BUSY");
- got_text=TRUE;
- }
- if ( strstr(gb_util_str, "NO CARRIER") )
- {
- strcpy(last_ret, "NO CARRIER");
- got_text=TRUE;
- }
-
- if ( strstr(gb_util_str, "CONNECT") || strstr(gb_util_str, "2400") ||
- strstr(gb_util_str, "1200") || strstr(gb_util_str, "NNECT") )
- {
- strcpy(last_ret, "CONNECTED");
- got_text=TRUE;
- connected=TRUE;
- ok=TRUE;
- }
- }
-
- if ( bioskey(1) )
- {
- a=getk();
- if ( a == ESC )
- esc=TRUE;
- }
-
- }
- while ( !got_text && !esc && i < 256 && clock() < time_out );
-
- if ( clock() >= time_out )
- strcpy(last_ret, "TIMED OUT");
-
- }
- while ( !connected && !esc );
-
-
- return(ok);
- }
-
-
-
- // just to get someone started
- // assumes serial stuff already inited
- /* ---------------------- simple_term() ------------------ April 23,1995 */
- void simple_term(void)
- {
- short done=0;
- short a=0;
- short k=0;
-
- do
- {
- if ( bioskey(1) )
- {
- // user pressed a key
- a=getch();
- if ( !a )
- a=getch();
- if ( isascii(a) )
- {
- printf("%c", a);
- send_232(a);
- }
-
- switch ( a )
- {
- case ESC:
- done=1;
- break;
-
- case F1:
- print_help();
- break;
-
- case ALT_S:
- do_file_transfer();
- break;
-
- case ALT_O:
- edit_modem_parms();
- break;
-
- // put as many functions as you like in here
- }
- }
-
-
- if ( char_ready_232() )
- {
- k=get_232();
- if ( isascii(k) )
- {
- printf("%c", k);
- }
- }
-
- }
- while ( !done );
-
- }
-
-
- */
- #endif
-
-